<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/12/27 0027
 * Time: 15:15
 */

namespace Cohuna\Controllers;


use Cohuna\Services\PayService;
use Phalcon\Mvc\Controller;

class GatewayController extends Controller
{
    public function initialize()
    {
        $this->view->disable();
    }

    public function indexAction()
    {
        $format = trim($this->request->getHeader('Content-Type'));

        if($format === 'application/json'){
            $content = file_get_contents('php://input');
            $params = json_decode($content,true);
            if(empty($params)){
                return $this->response->setJsonContent(array('errCode'=>'INVALID_PARAMETER','errMsg'=>'参数异常'))->send();
            }

            $response = PayService::getInstance()->createAlipayTrade($params);

            var_export($response);

        }

    }
}